package cn.zust.edu.cn;
/**
 * 
 * @author czg
 * @since 2023/3/7 10:50
 */
class Rectangle implements IShape {
    Point ptTopLeft;
    Point ptTopRight;
    int width;
    int height;

    public Rectangle() {
    }

    public Rectangle(Point topLeft, int height, int width) {
        this.ptTopLeft = topLeft;
        this.height = height;
        this.width = width;
        this.ptTopRight = new Point(topLeft.x + width, topLeft.y);
    }

    @Override
    public double perimeter() {
        return 2 * (width + height);
    }

    @Override
    public double area() {
        return width * height;
    }

    @Override
    public void draw() {
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                if (y == 0 || y == height - 1 || x == 0 || x == width - 1) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}

